package com.sxbang.bms.controller.api;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("${api-url}")
public class ApiController {

    @RequestMapping("/index")
    public ModelAndView toIndex(ModelAndView modelAndView,@RequestParam(value="access_token",required = false) String acccessToken){
        modelAndView.setViewName("admin/index");
        if(acccessToken != null)
        {
            modelAndView.addObject("access_token",acccessToken);
        }else{
            modelAndView.addObject("access_token","");
        }
        return modelAndView;
    }

    @RequestMapping(value="/getPage")
    public ModelAndView getPage(ModelAndView modelAndView, String pageName,
                                @RequestParam(value="access_token",required = false) String acccessToken){
        modelAndView.setViewName(pageName);
//        if(acccessToken != null)
//        {
//            modelAndView.addObject("access_token",acccessToken);
//        }else{
//            modelAndView.addObject("access_token","");
//        }
        return modelAndView;
    }

}
